/*
 *    This file is part of CeluMap.
 *
 *    CeluMap is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU Lesser General Public License as published by
 *    the Free Software Foundation; either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    CeluMap is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *    Copyright 2006, 2007, 2008 Gonzalo Merayo
 *    gonzalo (at) celumap.com.ar
 *    www.celumap.com.ar
 *
 */

package map;

import figures.Figure;
import figures.FigureIterator;
import geometry.Rectangle;

public class TextsMap implements Map {

	Map m = null;
	
	public TextsMap(Map map){
		m = map;
	}
	
	public FigureIterator getFigures(Rectangle area) {
		return new Iterator(area, m.getFigures(area));
	}
	
	private class Iterator implements FigureIterator{
		Rectangle a=null;
		FigureIterator i = null;
		Figure f=null;
		public Iterator(Rectangle area, FigureIterator fi){
			a = area;
			i = fi;
			advance();
		}
		
		public boolean hasNext() {
			return f!=null;
		}

		public Figure next() {
			Figure ff = f;
			advance();
			return ff;
		}

		private void advance() {
			/*
			if(i.hasNext())
				do{
					f = i.next();
					if(f.getBoundingBox().colides(a))
						f = new MovingText(f);
					else
						f = null;
				}while(f == null && i.hasNext());
			if(!i.hasNext())
				f = null;
				*/
		}	
	}
}
